DECLARE SUB RoomInfo ()
DECLARE SUB ParkInfo ()
DECLARE SUB CenterText ()
DECLARE SUB DissolveScreen ()
DECLARE SUB SaveGame ()
DECLARE SUB HitAnyKey ()
'$INCLUDE: 'c:\bc7\programs\yoshi\global.bi'

SUB CannotDo

  a = INT((9) * RND) + 1
  IF a = 1 THEN PRINT "You cannot do that here."
  IF a = 2 THEN PRINT "No can do, Kemosabe."
  IF a = 3 THEN PRINT "The inherent laws of the universe will not allow that."
  IF a = 4 THEN PRINT "That is not a valid command."
  IF a = 5 THEN PRINT "Please rephrase that command."
  IF a = 6 THEN PRINT "Your head spins at the very thought."
  IF a = 7 THEN PRINT "This game doesn't come with a spell checker, you know."
  IF a = 8 THEN PRINT "That wouldn't be prudent at this juncture."
  IF a = 9 THEN PRINT "Oops!  That doesn't work here."
  
END SUB

SUB CannotGo

  COLOR 15, 0, 9
  PRINT "You cannot go that direction."
  COLOR 7, 0, 8

END SUB

SUB CenterText

  LOCATE CSRLIN, 40 - INT(LEN(Text) / 2)
  PRINT Text

END SUB

SUB Dead
  COLOR 20, 0, 9
  PRINT
  PRINT TAB(15); "You are DEAD!"
  PRINT
  COLOR 11, 0, 9
  PRINT "Would you like to play again? ";
GetThatInput:
  LOCATE , , 1
  Temp = ""
  DO
  Temp = INKEY$
  Temp = UCASE$(Temp)
  LOOP UNTIL LEN(Temp) > 0
  IF Temp = "Y" THEN PRINT "yes": GOTO PlayAgain
  IF Temp = "N" THEN PRINT "no": GOTO TheEnd
  LOCATE , , 0
  GOTO GetThatInput

TheEnd:
  LOCATE , , 0
  COLOR 9, 0, 9
  PRINT : PRINT TAB(15); "The End."
  COLOR 7, 0, 8
  HitAnyKey
  DissolveScreen
  END

PlayAgain:
  RUN "\kcck\yoshi\yoshi.exe"

END SUB

SUB Help
  LOCATE , , 0
  CLS
  PRINT
  COLOR 11, 0, 9
  PRINT "  COMMANDS:"
  PRINT
  COLOR 15, 0, 8
  PRINT "  N";
  COLOR 7, 0, 8
  PRINT " - go north"
  COLOR 15, 0, 8
  PRINT "  S";
  COLOR 7, 0, 8
  PRINT " - go south"
  COLOR 15, 0, 8
  PRINT "  E";
  COLOR 7, 0, 8
  PRINT " - go east"
  COLOR 15, 0, 8
  PRINT "  W";
  COLOR 7, 0, 8
  PRINT " - go west"
  COLOR 15, 0, 8
  PRINT "  SEARCH";
  COLOR 7, 0, 8
  PRINT " - search the room for interesting things"
  COLOR 15, 0, 8
  PRINT "  USE <item>";
  COLOR 7, 0, 8
  PRINT " - use an item"
  COLOR 15, 0, 8
  PRINT "  GET <item>";
  COLOR 7, 0, 8
  PRINT " - get an item"
  COLOR 15, 0, 8
  PRINT "  I";
  COLOR 7, 0, 8
  PRINT " - inspect your inventory"
  COLOR 15, 0, 8
  PRINT "  LOOK";
  COLOR 7, 0, 8
  PRINT " - clear screen and reprint room description"
  COLOR 15, 0, 8
  PRINT "  HELP";
  COLOR 7, 0, 8
  PRINT " - display this screen"
  COLOR 15, 0, 8
  PRINT "  SAVE";
  COLOR 7, 0, 8
  PRINT " - save the current game"
  COLOR 15, 0, 8
  PRINT "  QUIT";
  COLOR 7, 0, 8
  PRINT " - quit the game"
  PRINT
  PRINT
  Text = "Discover other commands for yourself - you'll need them.": CenterText
  COLOR 7, 0, 8
  HitAnyKey
END SUB

SUB HitAnyKey
DO
  LOOP WHILE INKEY$ = ""
END SUB

SUB Inventory
  COLOR 15, 0, 9
  PRINT "Your inventory:"
  COLOR 7, 0, 8
  IF atomicbomb = 1 THEN PRINT " atomic bomb (homemade)"
  IF bananaslug = 1 THEN PRINT " banana slug"
  IF bathroomkey = 1 THEN PRINT " bathroom key"
  IF beachumbrella = 1 THEN PRINT " beach umbrella"
  IF birdseed = 1 THEN PRINT " birdseed"
  IF birthdaycard = 1 THEN PRINT " birthday card"
  IF branch = 1 THEN PRINT " branch"
  IF brillopad = 1 THEN PRINT " Brillo pad"
  IF camera = 1 OR camera = 2 THEN PRINT " poloriod camera"
  IF canopener = 1 THEN PRINT " can opener"
  IF hockeymask = 1 OR hockeymask = 2 THEN PRINT " hockey mask"
  IF kaopectate = 1 THEN PRINT " bottle of kaopectate"
  IF lampshade = 1 OR lampshade = 2 THEN PRINT " tassled lampshade"
  IF oilyrags = 1 THEN PRINT " oily rags"
  IF photo = 1 THEN PRINT " photograph of UFO"
  IF popsiclesticks = 1 THEN PRINT " popsicle sticks"
  IF prybar = 1 THEN PRINT " pry bar"
  IF qtip = 1 THEN PRINT " Q-Tip"
  IF smellybone = 1 THEN PRINT " smelly bone"
  IF torch = 1 THEN PRINT " unlit torch"
  IF torch = 2 THEN PRINT " lit torch"
  IF twentydollarbill = 1 THEN PRINT " twenty dollar bill"
  IF (twentydollarbill = 0 OR twentydollarbill = 2) AND atomicbomb = 0 AND (qtip = 0 OR qtip = 2) AND (canopener = 0 OR canopener = 2) AND (bananaslug = 0 OR bananaslug = 2) AND bathroomkey = 0 AND beachumbrella = 0 AND birdseed = 0 AND (branch = 0  _
OR branch = 2) AND (brillopad = 0 OR brillopad = 2) AND (camera = 0 OR camera = 2) AND (hockeymask = 0 OR hockeymask = 2) AND (lampshade = 0 OR lampshade = 2) AND (oilyrags = 0 OR oilyrags = 2) AND (kaopectate = 0 OR kaopecate = 2) AND (photo = 0 OR _
 photo = 2) AND popsiclesticks = 0 AND prybar = 0 AND (smellybone = 0 OR smellybone = 2) AND torch = 0 THEN PRINT " Nothing!  Absolutely nothing!  Stupid!  You're so stupid!"
END SUB

SUB Quit
  COLOR 11, 0, 9: PRINT
  PRINT "Are you sure that you want to quit? ";
  LOCATE , , 1

QuitSub:
  Temp$ = ""
  DO
  Temp$ = INKEY$
  Temp$ = UCASE$(Temp$)
  LOOP UNTIL LEN(Temp$) > 0
  IF Temp$ = "N" THEN LOCATE , , 0: PRINT "no": GOTO NotQuit
  IF Temp$ = "Y" THEN LOCATE , , 0: PRINT "yes": GOTO WantToSave
  GOTO QuitSub

WantToSave:
  PRINT
  PRINT "Would you like to save your game? ";
  LOCATE , , 1

WantToSaveSub:
  Temp$ = ""
  DO
  Temp$ = INKEY$
  Temp$ = UCASE$(Temp$)
  LOOP UNTIL LEN(Temp$) > 0
  IF Temp$ = "Y" THEN GOTO YesSave
  IF Temp$ = "N" THEN GOTO NoSave
  GOTO WantToSaveSub

YesSave:
  LOCATE , , 0
  PRINT "yes"
  PRINT
  SaveGame
  COLOR 7, 0, 8
  HitAnyKey
  DissolveScreen
  END

NoSave:
  LOCATE , , 0
  PRINT "no"
  COLOR 7, 0, 8
  HitAnyKey
  DissolveScreen
  END

NotQuit:
  COLOR 7, 0, 8

END SUB

SUB RestoreGame
  LOCATE , , 0
  ON LOCAL ERROR RESUME NEXT
  OPEN "kcck\yoshi\saved.gam" FOR INPUT AS #1
  IF ERR > 0 THEN PRINT : PRINT "There is no saved game.  You will start from the beginning.": GOTO NoFile
  INPUT #1, RestoreRoom, searchfield, talkrhino, chickenhit, fbitalk, fbi, beach1search, stomach, talkman, getmoney, curerhino, birdseed, stench, rustygrate, dumpstersearch, cleangrave, fountainsearch, drinkbeer, road1search, garagedoor,  _
birthdaycard, twentydollarbill, hockeymask, kaopectate, camera, photo, smellybone, beachumbrella, popsiclesticks, bathroomkey, lampshade, prybar, brillopad, torch, branch, oilyrags, bananaslug, pantrydoor, canopener, qtip, atomicbomb
  CLOSE
  RestoringRoom = 1
  IF RestoreRoom = 1400 OR RestoreRoom = 1500 OR RestoreRoom = 1600 OR RestoreRoom = 1700 OR RestoreRoom = 1800 OR RestoreRoom = 2500 OR RestoreRoom = 2600 THEN ParkInfo
  RoomInfo

NoFile:
  HitAnyKey
  ON LOCAL ERROR GOTO 0
  GOTO EndOfSub

EndOfSub:
END SUB

SUB SaveGame
  ON LOCAL ERROR RESUME NEXT
  OPEN "kcck\yoshi\saved.gam" FOR INPUT AS #1
  IF ERR > 0 THEN CLOSE #1: GOTO DoTheSaveThing
  CLOSE #1
  PRINT "There is already a saved game.  Overwrite? ";
  LOCATE , , 1
  Temp$ = ""
  DO
  Temp$ = INKEY$
  Temp$ = UCASE$(Temp$)
  LOOP UNTIL LEN(Temp$) > 0
  IF Temp$ = "Y" THEN PRINT "yes": GOTO DoTheSaveThing
  IF Temp$ = "N" THEN PRINT "no": COLOR 15, 0, 9: PRINT "  Game not saved.": LOCATE , , 0
  GOTO EndofTheSaveSub

DoTheSaveThing:
  COLOR 15, 0, 9
  OPEN "\kcck\yoshi\saved.gam" FOR OUTPUT AS #1
  PRINT #1, RestoreRoom, searchfield, talkrhino, chickenhit, fbitalk, fbi, beach1search, stomach, talkman, getmoney, curerhino, birdseed, stench, rustygrate, dumpstersearch, cleangrave, fountainsearch, drinkbeer, road1search, garagedoor,  _
birthdaycard, twentydollarbill, hockeymask, kaopectate, camera, photo, smellybone, beachumbrella, popsiclesticks, bathroomkey, lampshade, prybar, brillopad, torch, branch, oilyrags, bananaslug, pantrydoor, canopener, qtip, atomicbomb
  PRINT "  Game saved."
  CLOSE #1
  LOCATE , , 0
  
EndofTheSaveSub:
  COLOR 7, 0, 8
END SUB

